/*
	This file is part of Erosion, a clone of Qix
	Copyright (c) 2009 Bill Whitacre

	Permission is hereby granted, free of charge, to any person obtaining a copy
	of this software and associated documentation files (the "Software"), to deal
	in the Software without restriction, including without limitation the rights
	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
	copies of the Software, and to permit persons to whom the Software is
	furnished to do so, subject to the following conditions:

	The above copyright notice and this permission notice shall be included in
	all copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
	THE SOFTWARE.
*/

#ifndef FONT_SYSTEM_H
#define FONT_SYSTEM_H

#if defined(_MSC_VER)||defined(__WIN32__)
#	include <windows.h>
#endif

#include <stdlib.h>
#include <stdio.h>

#include <ft2build.h>
#include <freetype/freetype.h>
#include <freetype/ftglyph.h>
#include <freetype/ftoutln.h>
#include <freetype/fttrigon.h>

typedef struct rat_texture_font
{
	float pt,*wids,*bears,*hoss;
	int *qvws,*qvhs;
	float *qtws,*qths;
	unsigned int *textures;
} rat_texture_font;

typedef struct rat_glyph_font
{
	float pt;
	FT_Face face;
} rat_glyph_font;

#ifdef __cplusplus
extern "C" {
#endif

int rat_start_font_system();
void rat_stop_font_system();

rat_glyph_font *rat_glyph_font_load(char *filename,int pt);
rat_texture_font *rat_texture_font_from_glyph_font(rat_glyph_font *font);

void rat_glyph_font_destroy(rat_glyph_font *font);
void rat_texture_font_destroy(rat_texture_font *font);

void rat_set_text_color(const float *rgba);
void rat_get_text_color(float *rgba);

float rat_texture_font_height(rat_texture_font *font);
float rat_texture_font_text_length(rat_texture_font *font,char *text);
float rat_texture_font_glyph_length(rat_texture_font *font,char ch);

void rat_texture_font_render_text(rat_texture_font *font,float x,float y,char *text);
void rat_texture_font_render_text_notform(rat_texture_font *font,char *text);

void rat_texture_font_render_glyph_at(rat_texture_font *font,float x,float y,char ch);
void rat_texture_font_render_glyph_centered(rat_texture_font *font,float x,float y,float ang,float sclx,float scly,char ch);

#ifdef __cplusplus
}
#endif

#endif

